package surfing.chatting.client;

import java.util.Map;

import javax.swing.ImageIcon;

import surfing.chatting.tcp.TcpFactory;
import surfing.chatting.ui.label.LabelUser;
import surfing.chatting.union.Robot;

public class UserMe extends User {
	public Robot robot = new Robot("00000", "robot");
	public User group;

	public UserMe(Map<String, Object> map) {
		super(map);
	}

	public UserMe(String id, String name) {
		super(id, name);
	}

	public void set(Map<String, Object> map) {
		super.setId(map.get("id").toString());
		super.setName(map.get("name").toString());
		Object object = map.get("head");
		byte[] b = (byte[]) object;
		if (object != null) {
			super.setHeadIcon(new ImageIcon(b));
		}
		super.setLabel(new LabelUser(this));
	}

	@Override
	public void setOnline(boolean isOnline) {
		
		super.setOnline(isOnline);
	}

	public void talkToOther(Map<String, Object> map) {
		map.put("label", "@msg");
		map.put("id", super.getId());
		TcpFactory.getClient().send(map);
	}

	public String talkToRobot(String msg) {
		return robot.talk(msg);
	}

	public void talkToGroup(Map<String, Object> map) {
		map.put("label", "msg");
		map.put("id", super.getId());
		TcpFactory.getClient().send(map);
	}
}
